package cn.itrip.auth.controller;

import cn.itrip.common.RedisUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("/test")
//@Api 标注该类是一个swagger的资源类 放在类上
@Api(value = "测试swagger的类",tags = "{测试swagger的类}")
public class TestController {

    //进入swagger
//    http://localhost:8080/swagger-ui.html


//    @Resource
//    private StringRedisTemplate stringRedisTemplate;

    //编写redis工具类实现redis操作
    @Resource
    private RedisUtils redisUtils;

    @ApiOperation(value = "测试swagger的方法",notes = "你好swagger",httpMethod = "POST",protocols = "http")
    @RequestMapping(value = "/swagger",method = RequestMethod.POST)
//    使用ApiParam注解时必须加上RequestParam注解否则无法正确显示需求
    public void  testSwagger(@ApiParam(value = "aa",name = "bb",defaultValue = "默认值cc",required = true)@RequestParam String bb,@RequestParam("name") String name){
        System.out.println(bb);
//         stringRedisTemplate.opsForValue().set("name",bb);
//         stringRedisTemplate.getExpire("name");//获取这个值的剩余有效时间
//        System.out.println(stringRedisTemplate.getExpire("name"));
        System.out.println(name);
    }
}
